package cn.sdormitory.violative.entity;


import cn.hutool.core.date.DatePattern;
import cn.sdormitory.common.BaseEntity;
import cn.sdormitory.violative.enums.ViolationPatrolStatus;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@EqualsAndHashCode(callSuper = true)
@Data
@TableName("t_violation_patrol")
@Accessors(chain = true)
public class ViolationPatrol extends BaseEntity<ViolationPatrol,Long> {
    @ApiModelProperty(value = "违纪学员头像")
    private String cover;

    @ApiModelProperty(value = "违纪图片列表")
    private String images;

    @ApiModelProperty(value = "班级编号")
    private Long classId;

    @TableField(exist = false)
    private String className;

    @ApiModelProperty(value = "学生编号")
    private Long studentId;

    @TableField(exist = false)
    private String studentName;

    @ApiModelProperty(value = "违纪学生数量")
    private Integer studentNum;

    @ApiModelProperty("违纪类型")
    private Integer violationType;

    @ApiModelProperty(value = "违纪备注")
    private String note;

    @ApiModelProperty("违纪处理内容")
    private String handleContent;

    @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = "GMT+8")
    @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    @ApiModelProperty(value = "违纪时间")
    private Date violationTime;

    @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = "GMT+8")
    @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    @ApiModelProperty(value = "提交时间")
    private Date submitTime;

    @ApiModelProperty(value = "状态")
    private Integer status;

    public ViolationPatrol setStatus(Integer status) {
        this.status = status;
        this.statusText = status == null
                ? null
                : ViolationPatrolStatus.instanceOfThrow(status).getText();
        return this;
    }

    @TableField(exist = false)
    private String statusText;
}
